package com.thoughtworks.collection;

import sun.reflect.generics.reflectiveObjects.NotImplementedException;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class Flaten {

    Integer[][] array;
    public Flaten(Integer[][] array) {
        this.array = array;
    }

    public List<Integer> transformToOneDimesional() {
        ArrayList<Integer> list = new ArrayList<>();
        for (Integer[] array1 :array) {
            for (Integer element : array1) {
                list.add(element);
            }
        }
        return list;
    }

    public List<Integer> transformToUnrepeatedOneDimesional() {
        ArrayList<Integer> list = new ArrayList<>();
        for (Integer[] array1 :array) {
            for (Integer element : array1) {
                list.add(element);
            }
        }
        ArrayList<Integer> list2 = new ArrayList<Integer>();
        for(Integer i:list){
            if(!list2.contains(i)){
                list2.add(i);
            }
        }

        return list2;
    }
}
